/**
 * 
 */
package com.shine.icis.hbean;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import org.apache.struts2.json.annotations.JSON;

import com.shine.icis.dto.SubmitConfig;

/**
 * 报送日志，必要时可记到数据库中
 * @author zsy
 *
 */
public class SubmitLog implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1998411859294309098L;
	private String id;
	private String saveDir;//保存目录
	private String companyCode;//报送机构
	private String internalVersion;//内部版本号
	private String interfaceVersion;//接口规范版本号
	private boolean increment;//导出方式， 是否增量
	private boolean resubmitted;//是否重报
	private String dataDate;//数据日期
	private String remark;//备注
	private Date operateTime;//操作时间
	private String operator;//操作者
	
	private Set<SubmitFile> submitFiles;//报送的文件列表

	public SubmitLog() {
		
	}
	
	public SubmitLog(SubmitConfig cfg) {
		saveDir = cfg.getSaveDir();
		companyCode = cfg.getCompanyCode();
		internalVersion = cfg.getVersion();
		interfaceVersion = cfg.getInterfaceVersion();
		operateTime = new Date();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getSaveDir() {
		return saveDir;
	}
	
	public void setSaveDir(String saveDir) {
		this.saveDir = saveDir;
	}
	
	public String getCompanyCode() {
		return companyCode;
	}

	public void setCompanyCode(String companyCode) {
		this.companyCode = companyCode;
	}

	public String getInternalVersion() {
		return internalVersion;
	}

	public void setInternalVersion(String internalVersion) {
		this.internalVersion = internalVersion;
	}

	public String getInterfaceVersion() {
		return interfaceVersion;
	}

	public void setInterfaceVersion(String interfaceVersion) {
		this.interfaceVersion = interfaceVersion;
	}

	public boolean isIncrement() {
		return increment;
	}

	public void setIncrement(boolean increment) {
		this.increment = increment;
	}

	public boolean isResubmitted() {
		return resubmitted;
	}

	public void setResubmitted(boolean resubmitted) {
		this.resubmitted = resubmitted;
	}

	public String getDataDate() {
		return dataDate;
	}

	public void setDataDate(String dataDate) {
		this.dataDate = dataDate;
	}
	public String getFormatDataDate() {
		StringBuffer date = new StringBuffer(dataDate);
		date.insert(6, "-").insert(4, "-");
		return date.toString();
	}
	public Set<SubmitFile> getSubmitFiles() {
		return submitFiles;
	}

	public void setSubmitFiles(Set<SubmitFile> submitFiles) {
		this.submitFiles = submitFiles;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JSON(format="yyyy-MM-dd HH:mm")
	public Date getOperateTime() {
		return operateTime;
	}

	public void setOperateTime(Date operateTime) {
		this.operateTime = operateTime;
	}

	public String getOperator() {
		return operator;
	}

	public void setOperator(String operator) {
		this.operator = operator;
	}
	
	public String getOperatorName() {
		return operator != null && !operator.trim().equals("") ? operator : "系统自动";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final SubmitLog other = (SubmitLog) obj;
		if (id == null) {
//			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
}

